<?php 
include("../inc/global.inc");
if($_POST[act]){
    if($_SESSION['chkCode']==$_POST['c_code']){
        $sql="select id,m_psw from member where m_user='$_POST[member_id]'";
		$rs=@mysql_query($sql);
        $row=@mysql_fetch_array($rs);
           if($row['id']){
		        if($row[m_psw]=$_POST[security_code]){
				  $psw=substr(md5($_POST[newpassword]),7,19);
				  @mysql_query("update member set m_psw='$psw' where id='".$row['id']."'");
				  
				  echo "<script>alert('密码重置成功');location='/login';</script>";
				}else{
				
				echo "<script>alert('安全码错误');location='javascript:history.go(-1)';</script>";
				}
		   }else{
		       
               echo "<script>alert('会员账号错误');location='javascript:history.go(-1)';</script>";
		   }
    }else{
      echo "<script>alert('验证码错误!');location='javascript:history.go(-1)';</script>";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>重置密码-三帝贸易网</title>
<link href="/css/body.css" rel="stylesheet" type="text/css" />
<link href="/css/head_2.css" rel="stylesheet" type="text/css" />
<link href="/css/foot.css" rel="stylesheet" type="text/css" />
<link href="css/join.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/join.js" type="text/javascript" charset="gb2312"></script>
</head>
<body>
<?php include("../inc/head_top.php")?>
<div class="top1 topside6">
<div style="float:left;width:388px;"><a href="/"><img src="/images/logo.gif" border="0"/></a></div>
<div class="onl"></div>
</div>
<div class="onl"></div>
<div id="mian" class="topside6 sideyellow1">
  <div class="title3 size12">重置密码
    <div class="onl"></div>
</div><div class="content size14">
<form name="form" action="" method="post" onSubmit="return checkform()">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="side">
      <input type="hidden" name="m_type" value="Free" />
      <tr>
        <td width="181" height="35" align="right">会员账号<font color="#FF0000">*</font>&nbsp;</td>
        <td width="574" height="35"><input name="member_id" type="text" size="20"></td>
      </tr>
      <tr>
        <td height="35" align="right">安全码<font color="#FF0000">*</font>&nbsp;</td>
        <td height="35"><input name="security_code" type="text" size="35"></td>
      </tr>
	  <tr>
        <td height="35" align="right">新密码<font color="#FF0000">*</font>&nbsp;</td>
        <td height="35"><input name="newpassword" type="password" size="35"></td>
      </tr>
	  <tr>
        <td height="35" align="right">确认新密码<font color="#FF0000">*</font>&nbsp;</td>
        <td height="35"><input name="newpassword2" type="password" size="35"></td>
      </tr>
      <tr>
        <td height="35" align="right">验证码<font color="#FF0000">*</font>&nbsp; </td>
        <td height="35"><input name="c_code" type="text" id="c_code" size="8" maxlength="6">
        &nbsp;&nbsp;<img src="../inc/chk_num.php" name="img" width="90" height="30" align="absmiddle" id="img">&nbsp;<a href="#" name="can not see" id="test">刷新</a></td>
      </tr>
      <tr>
        <td height="72" colspan="2" align="center">
		<input type="hidden" name="act" value="ok" />
		<input name="submit" type="submit" class="createbut" value="Go" />
		<br>
		<br>
		<br></td>
      </tr>
  </table></form>
</div>
</div>
<div id="foot" class="footside">
<?php include("../inc/foot.php");?>
</div>
</body>
</html>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
 if($("member_id").value==""){
    alert("请输入您的账号");
    $("member_id").focus();
    return false;
 }
 if($("security_code").value==""){
   alert("请输入您的安全码");
    $("security_code").focus();
    return false;
}

 if($("newpassword").value==""){
    alert("新密码");
    $("newpassword").focus();
    return false;
}
if($("newpassword").value!=$("newpassword2").value){
alert("您两次输入的密码不一致");
$("newpassword2").focus();
return false;
}


}

function test(img){
    var src=img.getAttribute("src");
    src=src+"?new="+Math.random(0,10);
    img.setAttribute("src",src);
}
function prepare(){
    var nav=document.getElementById("test");
    var name=nav.getAttribute("name");
    var str="can not see";
    if(name==str){
        nav.onclick=function(){
            var img=document.getElementById("img");
            test(img);
            return false;
        }
    }
}
window.onload=prepare;
</script>
